package com.ruoyi.crm.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.crm.domain.Clue;
import com.ruoyi.crm.domain.vo.BusinessVo;
import com.ruoyi.crm.domain.vo.ClueVo;
import com.ruoyi.crm.domain.vo.FalseClueVo;
import com.ruoyi.crm.domain.vo.TransformVo;
import com.ruoyi.crm.service.IBusinessService;
import com.ruoyi.crm.service.IClueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/crm/business/track")
public class BusinessTrackController  extends BaseController {

    @Autowired
    private IBusinessService businessService;

    /**
     * 商机跟进
     */
    @Log(title = "商机跟进记录", businessType = BusinessType.EXPORT)
    @PostMapping
    public AjaxResult list(@RequestBody BusinessVo businessVo)
    {
        businessVo.setStatus(Clue.Status.JXZ.getValue());
        return toAjax(businessService.updateBusiness(businessVo));
    }

    /**
     * 踢回公海
     */
    @Log(title = "商机跟进记录", businessType = BusinessType.EXPORT)
    @PutMapping("/giveBack/{id}")
    public AjaxResult giveBack(@RequestBody FalseClueVo falseClueVo)
    {
        return toAjax(businessService.giveBack(falseClueVo));
    }

    /**
     * 捞取
     */
    @Log(title = "线索跟进记录", businessType = BusinessType.EXPORT)
    @PutMapping("/reset/{id}")
    public AjaxResult reset(@RequestBody FalseClueVo falseClueVo)
    {
        return toAjax(businessService.reset(falseClueVo));
    }

    /**
     * 转客户
     */
    @Log(title = "线索跟进记录", businessType = BusinessType.EXPORT)
    @PutMapping("/transform/{id}")
    public AjaxResult transform(@RequestBody TransformVo transformVo)
    {
        return toAjax(businessService.transform(transformVo));
    }


}
